﻿using DocumentFormat.OpenXml.Lite.Helper;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.Types;
using DocumentFormat.OpenXml.Lite.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace DocumentFormat.OpenXml.Lite.WordprocessingML.Word.SectionProperties
{
    [XmlRoot("pgSz", Namespace = Constants.WordMain)]
    public class PageSize : XmlSerializable, ISectionPropElement
    {
        [Optional]
        [XmlAttribute("w", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<uint> Width { get; set; }

        [Optional]
        [XmlAttribute("h", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<uint> Height { get; set; }

        [Optional]
        [XmlAttribute("orient", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<ST_PageOrientation> Orientation { get; set; }

        [Optional]
        [XmlAttribute("code", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<int> PrinterPaperCode { get; set; }

        public PageSize() { }

        public void Copy(object obj)
        {
            if (obj is PageSize)
            {
                this.Width = (obj as PageSize).Width;
                this.Height = (obj as PageSize).Height;
                this.Orientation = (obj as PageSize).Orientation;
                this.PrinterPaperCode = (obj as PageSize).PrinterPaperCode;
            }
        }
    }
}
